module.exports = {
  handler(req,res,next){
    let doc = req.body;
    let userID = doc.userID;
    let mobile = doc.mobile;
    let authCode = doc.authCode;
    req.redis.get("mobile:"+mobile,function(err,data){
      if (err){
        return res.reply({code:2001,message:err,result:false});
      } else{
        if(data!==authCode){
          return res.reply({code:2002,message:"验证码错误!",result:false});
        }else{
          req.mongo.collection("user").updateOne({"_id":userID},{$set:{"tel":mobile}},{upsert:true},(e,r)=>{
            if(e) return res.err.mongoError(e);
            return res.reply({code:0,message:"手机绑定成功!",result:true});
          })
        }
      }
    });
  }
}